package com.micai.springboot.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.micai.springboot.entity.RoleEntity;
import com.micai.springboot.mapper.RoleMapper;
import com.micai.springboot.service.RoleService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述：
 * <p>
 * Author: 赵新国
 * Date: 2017/10/24 18:36
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RoleEntity> implements RoleService {

    private static final Logger logger = LoggerFactory.getLogger(RoleServiceImpl.class);

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public Page<RoleEntity> getRoleByPage(int pageNum, int pageSize, String name) {
        PageHelper.startPage(pageNum, pageSize);
        Map<String, Object> columnMap = new HashMap<String, Object>(16);
        if (!StringUtils.isBlank(name)) {
            columnMap.put("name", name);
        }
        Page<RoleEntity> roleEntities = roleMapper.findByPage(columnMap);
        if (roleEntities == null) {
            return null;
        }
        return roleEntities;
    }
}
